from alembic import op
import sqlalchemy as sa
from uuid import uuid4
from app.basic.company.models.company_models import Company
from app.basic.user.models.user_models import User
from app.basic.user.models.role_models import Role
from app.basic.store.models.store_models import Store
from app.basic.product.models.product_models import Product, ProductCategory

from app.inventory.product_storage.models.product_storage_models import ProductStorageType
from app.basic.uom.models.uom_models import Uom
from app.basic.uom.models.uom_category_models import UomCategory
from datetime import datetime
from app.inventory.location.models import Location, LocationType
from app.inventory.order.models import OrderType, Order
from app.inventory.quant.models import Lot, Quant
from sqlalchemy_utils.types import PasswordType

# revision identifiers, used by Alembic.
revision = '6ea1b38aba41'
down_revision = '614e1673cb90'
branch_labels = None
depends_on = '614e1673cb90'


def upgrade():
    company_1_id = uuid4().__str__()
    company_2_id = uuid4().__str__()
    store_1_company_1_id = uuid4().__str__()
    store_2_company_1_id = uuid4().__str__()
    store_3_company_1_id = uuid4().__str__()
    store_1_company_2_id = uuid4().__str__()
    store_2_company_2_id = uuid4().__str__()
    store_3_company_2_id = uuid4().__str__()
    user_admin_id = uuid4().__str__()
    user_1_company_1_id = uuid4().__str__()
    user_2_company_1_id = uuid4().__str__()
    user_1_company_2_id = uuid4().__str__()
    user_2_company_2_id = uuid4().__str__()
    role_1_company_1_id = uuid4().__str__()
    role_2_company_1_id = uuid4().__str__()
    role_1_company_2_id = uuid4().__str__()
    role_2_company_2_id = uuid4().__str__()
    uom_category_1_company_1 = uuid4().__str__()
    uom_category_1_company_2 = uuid4().__str__()
    uom_1_company_1 = uuid4().__str__()
    uom_1_company_2 = uuid4().__str__()
    product_category_1_company_1 = uuid4().__str__()
    product_category_1_company_2 = uuid4().__str__()
    product_storage_type_1_company_1 = uuid4().__str__()
    product_storage_type_1_company_2 = uuid4().__str__()
    product_1_company_1_id = uuid4().__str__()
    product_2_company_1_id = uuid4().__str__()
    product_1_company_2_id = uuid4().__str__()
    product_2_company_2_id = uuid4().__str__()
    from passlib.hash import pbkdf2_sha512
    target = User()
    target.password = '1402'
    new_password = pbkdf2_sha512.encrypt("1402")

    # ### commands auto generated by Alembic - please adjust! ###
    op.bulk_insert(Company.__table__,
                   [
                       {
                           'id': company_1_id,
                           'lsn': 1,
                           "title": "Apple",
                           "external_number": "100000",
                           "locale": "en_US",
                           "country": "US",
                           "currency": "USD",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': company_2_id,
                           'lsn': 2,
                           "title": "Yandex",
                           "external_number": "100001",
                           "locale": "ru_RU",
                           "country": "RU",
                           "currency": "RUB",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       }
                   ])

    op.bulk_insert(ProductCategory.__table__, [
        {
            'id': product_category_1_company_1,
            'lsn': 1,
            "company_id": company_1_id,
            "title": "Product Category 1",
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
        {
            'id': product_category_1_company_2,
            'lsn': 1,
            "company_id": company_2_id,
            "title": "Product Category 1",
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
    ])

    op.bulk_insert(UomCategory.__table__, [
        {
            'id': uom_category_1_company_1,
            'lsn': 1,
            "company_id": company_1_id,
            "title": "Uom category 1",
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
        {
            'id': uom_category_1_company_2,
            'lsn': 2,
            "company_id": company_2_id,
            "title": "Uom category 2",
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
    ])
    op.bulk_insert(Uom.__table__, [
        {
            'id': uom_1_company_1,
            'lsn': 1,
            "company_id": company_1_id,
            "title": "Uom 1",
            'uom_category_id': uom_category_1_company_1,
            'type': 'standart',
            'ratio': 2,
            'precision': 2,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
        {
            'id': uom_1_company_2,
            'lsn': 1,
            "company_id": company_2_id,
            "title": "Uom 1",
            'uom_category_id': uom_category_1_company_2,
            'type': 'standart',
            'ratio': 2,
            'precision': 2,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
    ])
    op.bulk_insert(Product.__table__, [
        {
            'id': product_storage_type_1_company_1,
            'lsn': 1,
            "company_id": company_1_id,
            "title": "Product Storage type 1",
            'product_type': 'storable',
            'uom_id': uom_1_company_1,
            'product_category_id': product_category_1_company_1,
            'barcode_list': ['111'],
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
        {
            'id': product_storage_type_1_company_2,
            'lsn': 2,
            "company_id": company_2_id,
            "title": "Product Storage type 1",
            'product_type': 'storable',
            'uom_id': uom_1_company_2,
            'barcode_list': ['111'],
            'product_category_id': product_category_1_company_2,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
    ])
    op.bulk_insert(Store.__table__,
                   [
                       {
                           'id': store_1_company_1_id,
                           'lsn': 1,
                           "company_id": company_1_id,
                           "title": "Apple Store New York",
                           "external_number": "100",
                           "address": "Gansevoort St",
                           "source": "internal",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': store_2_company_1_id,
                           'lsn': 2,
                           "company_id": company_1_id,
                           "title": "Apple Store Florida",
                           "external_number": "101",
                           "address": "Florida St",
                           "source": "internal",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': store_3_company_1_id,
                           'lsn': 2,
                           "company_id": company_1_id,
                           "title": "Apple Store Denver",
                           "external_number": "109",
                           "address": "Denver St",
                           "source": "internal",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': store_1_company_2_id,
                           'lsn': 1,
                           "company_id": company_2_id,
                           "title": "Yandex Market",
                           "external_number": "117",
                           "address": "Lenina 4",
                           "source": "internal",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': store_2_company_2_id,
                           'lsn': 2,
                           "company_id": company_2_id,
                           "title": "Yandex HUB Taxi",
                           "external_number": "108",
                           "address": "Stalina 90 st",
                           "source": "internal",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': store_3_company_2_id,
                           'lsn': 2,
                           "company_id": company_2_id,
                           "title": "Yandex Lavka Gamovniki",
                           "external_number": "102",
                           "address": "Burjuya 17 St",
                           "source": "internal",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       }
                   ])

    op.bulk_insert(Role.__table__,
                   [
                       {
                           "id": role_1_company_1_id,
                           'lsn': 2,
                           "title": "support",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                           "permission_allow_list": [
                               "user_create",
                               "user_edit",
                               "user_list",
                               "user_delete",
                               "user_get",
                           ],
                           "company_id": company_1_id
                       },
                       {
                           "id": role_2_company_1_id,
                           "title": "admin",
                           'lsn': 3,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                           'is_admin': True,
                           "permission_allow_list": [
                               "company_create",
                               "company_edit",
                               "company_list",
                               "company_delete",
                               "company_get",
                           ],
                           "company_id": company_1_id,
                           'company_ids': [
                               company_1_id,
                               company_2_id
                           ]
                       },
                       {
                           "id": role_1_company_2_id,
                           'lsn': 4,
                           "title": "support",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                           "permission_allow_list": [
                               "user_create",
                               "user_edit",
                               "user_list",
                               "user_delete",
                               "user_get",
                           ],
                           "company_id": company_2_id
                       },
                       {
                           "id": role_2_company_2_id,
                           'lsn': 5,
                           "title": "admin",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                           "permission_allow_list": [
                               "company_create",
                               "company_edit",
                               "company_list",
                               "company_delete",
                               "company_get",
                           ],
                           "company_id": company_2_id
                       }
                   ])
    op.bulk_insert(User.__table__,
                   [
                       {
                           "id": user_admin_id,
                           'lsn': 1,
                           "email": "admin@admin.ru",
                           "country": "US",
                           "locale": "en_US",
                           "phone_number": "+449534771093",
                           "nickname": "Admin",
                           "is_admin": True,
                           "company_id": company_1_id,
                           "company_ids": [company_1_id, company_2_id],
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                           "password": '1402'
                       },
                       {
                           "id": user_1_company_1_id,
                           'lsn': 3,
                           "email": "user1@apple.ru",
                           "country": "RU",
                           "locale": "ru_RU",
                           "phone_number": "+449534771093",
                           "nickname": "Albert",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                           "roles": [
                               role_1_company_1_id
                           ],
                           "is_admin": False,
                           "company_id": company_1_id,
                           "company_ids": [company_1_id],
                           "password": '1402'
                       },
                       {
                           "id": user_2_company_1_id,
                           'lsn': 4,
                           "email": "user2@apple.ru",
                           "country": "RU",
                           "locale": "ru_RU",
                           "phone_number": "+449534771093",
                           "nickname": "Albert",
                           "company_id": company_1_id,
                           "company_ids": [company_1_id],
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                           "roles": [
                               role_2_company_1_id
                           ],
                           "is_admin": False,
                           "password": '1402'
                       },
                       {
                           "id": user_1_company_2_id,
                           'lsn': 5,
                           "email": "user1@yandex.ru",
                           "country": "RU",
                           "locale": "ru_RU",
                           "phone_number": "+449534771093",
                           "nickname": "Albert",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                           "is_admin": False,
                           "company_id": company_2_id,
                           "company_ids": [company_2_id],
                           "roles": [
                               role_1_company_2_id
                           ],
                           "password": '1402'
                       },
                       {
                           "id": user_2_company_2_id,
                           'lsn': 6,
                           "email": "user2@yandex.ru",
                           "country": "RU",
                           "locale": "ru_RU",
                           "phone_number": "+449534771093",
                           "nickname": "Albert",
                           "is_admin": False,
                           "company_id": company_2_id,
                           "company_ids": [company_2_id],
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                           "roles": [
                               role_2_company_2_id
                           ],
                           "password": '1402'
                       }
                   ])

    location_type_partner_company_1 = uuid4().__str__()
    location_type_place_company_1 = uuid4().__str__()
    location_type_resource_company_1 = uuid4().__str__()
    location_type_package_company_1 = uuid4().__str__()
    location_type_zone_company_1 = uuid4().__str__()
    location_type_lost_company_1 = uuid4().__str__()
    location_type_inventory_company_1 = uuid4().__str__()
    location_type_scrap_company_1 = uuid4().__str__()
    location_type_scrapped_company_1 = uuid4().__str__()
    location_type_buffer_company_1 = uuid4().__str__()
    location_type_partner_company_2 = uuid4().__str__()
    location_type_place_company_2 = uuid4().__str__()
    location_type_resource_company_2 = uuid4().__str__()
    location_type_package_company_2 = uuid4().__str__()
    location_type_zone_company_2 = uuid4().__str__()
    location_type_lost_company_2 = uuid4().__str__()
    location_type_inventory_company_2 = uuid4().__str__()
    location_type_scrap_company_2 = uuid4().__str__()
    location_type_scrapped_company_2 = uuid4().__str__()
    location_type_buffer_company_2 = uuid4().__str__()
    op.bulk_insert(LocationType.__table__,
                   [
                       {
                           'id': location_type_partner_company_1,
                           'lsn': 1,
                           "company_id": company_1_id,
                           "title": "partner",
                           "location_class": "partner",
                           "is_can_negative": True,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_place_company_1,
                           'lsn': 2,
                           "company_id": company_1_id,
                           "title": "place",
                           "location_class": "place",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_resource_company_1,
                           'lsn': 3,
                           "company_id": company_1_id,
                           "title": "resource",
                           "location_class": "resource",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_package_company_1,
                           'lsn': 4,
                           "company_id": company_1_id,
                           "title": "package",
                           "location_class": "package",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_zone_company_1,
                           'lsn': 5,
                           "company_id": company_1_id,
                           "title": "zone",
                           "location_class": "zone",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_lost_company_1,
                           'lsn': 6,
                           "company_id": company_1_id,
                           "title": "lost",
                           "location_class": "lost",
                           "is_can_negative": True,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_inventory_company_1,
                           'lsn': 7,
                           "company_id": company_1_id,
                           "title": "inventory",
                           "location_class": "inventory",
                           "is_can_negative": True,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_scrap_company_1,
                           'lsn': 8,
                           "company_id": company_1_id,
                           "title": "scrap",
                           "location_class": "scrap",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_scrapped_company_1,
                           'lsn': 9,
                           "company_id": company_1_id,
                           "title": "scrapped",
                           "location_class": "scrapped",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_buffer_company_1,
                           'lsn': 10,
                           "company_id": company_1_id,
                           "title": "buffer",
                           "location_class": "buffer",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_partner_company_2,
                           'lsn': 1,
                           "company_id": company_2_id,
                           "title": "partner",
                           "is_can_negative": True,
                           "is_can_negative": False,
                           "location_class": "partner",
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_place_company_2,
                           'lsn': 2,
                           "company_id": company_2_id,
                           "title": "place",
                           "location_class": "place",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_resource_company_2,
                           'lsn': 3,
                           "company_id": company_2_id,
                           "title": "resource",
                           "location_class": "resource",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_package_company_2,
                           'lsn': 4,
                           "company_id": company_2_id,
                           "title": "package",
                           "location_class": "package",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_zone_company_2,
                           'lsn': 5,
                           "company_id": company_2_id,
                           "title": "zone",
                           "location_class": "zone",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_lost_company_2,
                           'lsn': 6,
                           "company_id": company_2_id,
                           "title": "lost",
                           "location_class": "lost",
                           "is_can_negative": True,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_inventory_company_2,
                           'lsn': 7,
                           "company_id": company_2_id,
                           "title": "inventory",
                           "location_class": "inventory",
                           "is_can_negative": True,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_scrap_company_2,
                           'lsn': 8,
                           "company_id": company_2_id,
                           "title": "scrap",
                           "location_class": "scrap",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_scrapped_company_2,
                           'lsn': 9,
                           "company_id": company_2_id,
                           "title": "scrapped",
                           "location_class": "scrapped",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                       {
                           'id': location_type_buffer_company_2,
                           'lsn': 10,
                           "company_id": company_2_id,
                           "title": "buffer",
                           "location_class": "buffer",
                           "is_can_negative": False,
                           'created_at': datetime.now(),
                           'updated_at': datetime.now(),
                       },
                   ])
    location_partner_company_1 = uuid4().__str__()
    location_place_company_1 = uuid4().__str__()
    location_resource_company_1 = uuid4().__str__()
    location_package_company_1 = uuid4().__str__()
    location_zone_company_1 = uuid4().__str__()
    location_lost_company_1 = uuid4().__str__()
    location_inventory_company_1 = uuid4().__str__()
    location_scrap_company_1 = uuid4().__str__()
    location_scrapped_company_1 = uuid4().__str__()
    location_buffer_company_1 = uuid4().__str__()
    location_partner_company_2 = uuid4().__str__()
    location_place_company_2 = uuid4().__str__()
    location_resource_company_2 = uuid4().__str__()
    location_package_company_2 = uuid4().__str__()
    location_zone_company_2 = uuid4().__str__()
    location_lost_company_2 = uuid4().__str__()
    location_inventory_company_2 = uuid4().__str__()
    location_scrap_company_2 = uuid4().__str__()
    location_scrapped_company_2 = uuid4().__str__()
    location_buffer_company_2 = uuid4().__str__()

    op.bulk_insert(Location.__table__, [
        {
            'id': location_partner_company_1,
            'lsn': 1,
            "company_id": company_1_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_1_id,
            'is_can_negative': True,
            'location_type_id': location_type_partner_company_1,
            'location_class': 'partner',
            "title": f"LOCATION_PARTNER_COMPANY 1",
        },
        {
            'id': location_resource_company_1,
            'lsn': 3,
            "company_id": company_1_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_1_id,
            "is_can_negative": False,
            'location_type_id': location_type_resource_company_1,
            'location_class': 'resource',
            "title": f"LOCATION_RESOURCE_COMPANY 1",
        },
        {
            'id': location_zone_company_1,
            'lsn': 5,
            "company_id": company_1_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_1_id,
            "is_can_negative": False,
            'location_type_id': location_type_zone_company_1,
            'location_class': 'zone',
            "title": f"LOCATION_ZONE_COMPANY 1",
        },

        {
            'id': location_lost_company_1,
            'lsn': 6,
            "company_id": company_1_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_1_id,
            'location_type_id': location_type_lost_company_1,
            'location_class': 'lost',
            'is_can_negative': True,
            "title": f"LOCATION_LOST_COMPANY 1",
        },
        {
            'id': location_inventory_company_1,
            'lsn': 7,
            "company_id": company_1_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_1_id,
            'location_type_id': location_type_inventory_company_1,
            'location_class': 'inventory',
            'is_can_negative': True,
            "title": f"LOCATION_INVENTORY_COMPANY 1",
        },
        {
            'id': location_scrap_company_1,
            'lsn': 8,
            "company_id": company_1_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_1_id,
            'location_type_id': location_type_scrap_company_1,
            'location_class': 'scrap',
            "is_can_negative": False,
            "title": f"LOCATION_SCRAP_COMPANY 1",
        },
        {
            'id': location_scrapped_company_1,
            'lsn': 9,
            "company_id": company_1_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_1_id,
            'location_type_id': location_type_scrapped_company_1,
            'location_class': 'scrapped',
            "is_can_negative": False,
            "title": f"LOCATION_SCRAPED_COMPANY 1",
        },
        {
            'id': location_buffer_company_1,
            'lsn': 10,
            "company_id": company_1_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_1_id,
            'location_type_id': location_type_buffer_company_1,
            'location_class': 'buffer',
            "is_can_negative": False,
            "title": f"LOCATION_BUFFER_COMPANY 1",
        },
        {
            'id': location_partner_company_2,
            'lsn': 11,
            "company_id": company_2_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_2_id,
            'location_type_id': location_type_partner_company_2,
            'location_class': 'partner',
            'is_can_negative': True,
            "title": f"LOCATION_PARTNER_COMPANY 2",
        },
        {
            'id': location_resource_company_2,
            'lsn': 13,
            "company_id": company_2_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_2_id,
            'location_type_id': location_type_resource_company_2,
            'location_class': 'resource',
            "is_can_negative": False,
            "title": f"LOCATION_RESOURCE_COMPANY 2",
        },
        {
            'id': location_zone_company_2,
            'lsn': 16,
            "company_id": company_2_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_2_id,
            'location_type_id': location_type_zone_company_2,
            'location_class': 'zone',
            "is_can_negative": False,
            "title": f"LOCATION_ZONE_COMPANY 2",
        },

        {
            'id': location_lost_company_2,
            'lsn': 17,
            "company_id": company_2_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_2_id,
            'location_type_id': location_type_lost_company_2,
            'location_class': 'lost',
            'is_can_negative': True,
            "title": f"LOCATION_LOST_COMPANY 2",
        },
        {
            'id': location_inventory_company_2,
            'lsn': 18,
            "company_id": company_2_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_2_id,
            'location_type_id': location_type_inventory_company_2,
            'location_class': 'inventory',
            "is_can_negative": False,
            "title": f"LOCATION_INVENTORY_COMPANY 2",
        },
        {
            'id': location_scrap_company_2,
            'lsn': 19,
            "company_id": company_2_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_2_id,
            'location_type_id': location_type_scrap_company_2,
            'location_class': 'scrap',
            "is_can_negative": False,
            "title": f"LOCATION_SCRAP_COMPANY 2",
        },
        {
            'id': location_scrapped_company_2,
            'lsn': 20,
            "company_id": company_2_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_2_id,
            'location_type_id': location_type_scrapped_company_2,
            'location_class': 'scrapped',
            "is_can_negative": False,
            "title": f"LOCATION_SCRAPED_COMPANY 2",
        },
        {
            'id': location_buffer_company_2,
            'lsn': 21,
            "company_id": company_2_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_2_id,
            'location_type_id': location_type_buffer_company_2,
            'location_class': 'buffer',
            "is_can_negative": False,
            "title": f"LOCATION_BUFFER_COMPANY 2",
        },
    ])
    op.bulk_insert(Location.__table__, [
        {
            'id': location_place_company_1,
            'lsn': 2,
            "company_id": company_1_id,
            'created_at': datetime.now(),
            'parent_id': location_zone_company_1,
            'updated_at': datetime.now(),
            'store_id': store_1_company_1_id,
            'location_type_id': location_type_place_company_1,
            'location_class': 'place',
            "is_can_negative": False,
            "title": f"LOCATION_PLACE_COMPANY 1",
        },

        {
            'id': location_package_company_1,
            'lsn': 4,
            "company_id": company_1_id,
            "parent_id": location_place_company_1,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_1_id,
            'location_type_id': location_type_package_company_1,
            'location_class': 'package',
            "is_can_negative": False,
            "title": f"LOCATION_PACKAGE_COMPANY 1",
        },
        {
            'id': location_place_company_2,
            'lsn': 12,
            "company_id": company_2_id,
            'parent_id': location_zone_company_2,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_2_id,
            'location_type_id': location_type_place_company_2,
            'location_class': 'place',
            "is_can_negative": False,
            "title": f"LOCATION_PLACE_COMPANY 2",
        },
        {
            'id': location_package_company_2,
            'lsn': 15,
            "company_id": company_2_id,
            "parent_id": location_place_company_2,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'store_id': store_1_company_2_id,
            'location_type_id': location_type_package_company_2,
            'location_class': 'package',
            "is_can_negative": False,
            "title": f"LOCATION_PACKAGE_COMPANY 2",
        },
    ])

    lot_1_company_1 = uuid4().__str__()
    lot_2_company_1 = uuid4().__str__()
    lot_1_company_2 = uuid4().__str__()
    lot_2_company_2 = uuid4().__str__()
    op.bulk_insert(Lot.__table__, [
        {
            'id': lot_1_company_1,
            'lsn': 1,
            "company_id": company_1_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'expiration_date': datetime.now(),
            'product_id': product_1_company_1_id,
            'external_number': 'lot1_external1',
        },
        {
            'id': lot_2_company_1,
            'lsn': 2,
            "company_id": company_2_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'expiration_date': datetime.now(),
            'product_id': product_2_company_1_id,
            'external_number': 'lot2_external1',
        },
        {
            'id': lot_1_company_2,
            'lsn': 3,
            "company_id": company_2_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'expiration_date': datetime.now(),
            'product_id': product_1_company_2_id,
            'external_number': 'lot1_external2',
        },
        {
            'id': lot_2_company_2,
            'lsn': 4,
            "company_id": company_2_id,
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
            'expiration_date': datetime.now(),
            'product_id': product_2_company_2_id,
            'external_number': 'lot2_external2',
        },
    ])
    quant_1_company_1 = uuid4().__str__()
    quant_2_company_1 = uuid4().__str__()
    quant_3_company_1 = uuid4().__str__()
    quant_1_company_2 = uuid4().__str__()
    quant_2_company_2 = uuid4().__str__()
    quant_3_company_2 = uuid4().__str__()
    # op.bulk_insert(Quant.__table__, [
    #     {
    #         'id': quant_1_company_1,
    #         'lsn': 1,
    #         "company_id": company_1_id,
    #         'created_at': datetime.now(),
    #         'updated_at': datetime.now(),
    #         'store_id': store_1_company_1_id,
    #         'lot_id': lot_1_company_1,
    #         'quantity': 100.0,
    #         'reserved_quantity': 0.0,
    #         'expiration_date': datetime.now(),
    #         'product_id': product_1_company_1_id,
    #         'uom_id': uom_1_company_1,
    #     },
    #     {
    #         'id': quant_2_company_1,
    #         'lsn': 2,
    #         "company_id": company_1_id,
    #         'created_at': datetime.now(),
    #         'updated_at': datetime.now(),
    #         'store_id': store_1_company_1_id,
    #         'lot_id': lot_2_company_1,
    #         'quantity': 200.0,
    #         'reserved_quantity': 0.0,
    #         'expiration_date': datetime.now(),
    #         'product_id': product_1_company_1_id,
    #         'uom_id': uom_1_company_1,
    #     },
    #     {
    #         'id': quant_1_company_2,
    #         'lsn': 4,
    #         "company_id": company_2_id,
    #         'created_at': datetime.now(),
    #         'updated_at': datetime.now(),
    #         'store_id': store_2_company_1_id,
    #         'lot_id': lot_1_company_2,
    #         'quantity': 100.0,
    #         'reserved_quantity': 0.0,
    #         'expiration_date': datetime.now(),
    #         'product_id': product_1_company_2_id,
    #         'uom_id': uom_1_company_2,
    #     },
    #     {
    #         'id': quant_2_company_2,
    #         'lsn': 5,
    #         "company_id": company_2_id,
    #         'created_at': datetime.now(),
    #         'updated_at': datetime.now(),
    #         'store_id': store_2_company_1_id,
    #         'lot_id': lot_2_company_2,
    #         'quantity': 200.0,
    #         'reserved_quantity': 0.0,
    #         'expiration_date': datetime.now(),
    #         'product_id': product_1_company_2_id,
    #         'uom_id': uom_1_company_2,
    #     },
    # ])
    order_type_inc_company_1 = uuid4().__str__()
    order_type_out_company_1 = uuid4().__str__()
    order_type_int_company_1 = uuid4().__str__()
    order_type_inc_company_2 = uuid4().__str__()
    order_type_out_company_2 = uuid4().__str__()
    order_type_int_company_2 = uuid4().__str__()
    op.bulk_insert(OrderType.__table__, [
        {
            'id': order_type_inc_company_1,
            'company_id': company_1_id,
            'prefix': 'INC',
            'title': 'Incoming type',
            'order_class': 'incoming',
            'allowed_location_src_ids': [location_partner_company_1, ],
            'exclusive_location_src_ids': None,
            'allowed_location_dest_ids': [location_buffer_company_1, ],
            'exclusive_location_dest_ids': None,
            'backorder_order_type_id': None,
            'backorder_action_type': 'ask',
            'store_id': None,
            'partner_id': None,
            'reservation_method': 'at_confirm',
            'reservation_time_before': 0,
            'allowed_package_ids': [],
            'exclusive_package_ids': None,
            'is_homogeneity': False,
            'is_allow_create_package': True,
            'is_can_create_order_manualy': True,
            'is_overdelivery': False,
            'created_by': user_1_company_1_id,
            'edited_by': user_1_company_1_id,
            'barcode': '2132132131231',
            'strategy': 'fefo',
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
        {
            'id': order_type_out_company_1,
            'company_id': company_1_id,
            'prefix': 'OUT',
            'title': 'OUT',
            'order_class': 'incoming',
            'allowed_location_src_ids': [location_buffer_company_1, ],
            'exclusive_location_src_ids': None,
            'allowed_location_dest_ids': [location_partner_company_1, ],
            'exclusive_location_dest_ids': None,
            'backorder_order_type_id': None,
            'backorder_action_type': 'ask',
            'store_id': None,
            'partner_id': None,
            'reservation_method': 'at_confirm',
            'reservation_time_before': 0,
            'allowed_package_ids': [],
            'exclusive_package_ids': None,
            'is_homogeneity': False,
            'is_allow_create_package': True,
            'is_can_create_order_manualy': True,
            'is_overdelivery': False,
            'created_by': user_1_company_1_id,
            'edited_by': user_1_company_1_id,
            'barcode': '2132132131231',
            'strategy': 'fefo',
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
        {
            'id': order_type_int_company_1,
            'company_id': company_1_id,
            'prefix': 'INT',
            'title': 'Internal type',
            'order_class': 'incoming',
            'allowed_location_src_ids': [],
            'exclusive_location_src_ids': None,
            'allowed_location_dest_ids': [],
            'exclusive_location_dest_ids': None,
            'backorder_order_type_id': None,
            'backorder_action_type': 'ask',
            'store_id': None,
            'partner_id': None,
            'reservation_method': 'at_confirm',
            'reservation_time_before': 0,
            'allowed_package_ids': [],
            'exclusive_package_ids': None,
            'is_homogeneity': False,
            'is_allow_create_package': True,
            'is_can_create_order_manualy': True,
            'is_overdelivery': False,
            'created_by': user_1_company_1_id,
            'edited_by': user_1_company_1_id,
            'barcode': '2132132131231',
            'strategy': 'fefo',
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
        # Company 2
        {
            'id': order_type_inc_company_2,
            'company_id': company_2_id,
            'prefix': 'INC',
            'title': 'Incoming type',
            'order_class': 'incoming',
            'allowed_location_src_ids': [location_partner_company_2, ],
            'exclusive_location_src_ids': None,
            'allowed_location_dest_ids': [location_buffer_company_2, ],
            'exclusive_location_dest_ids': None,
            'backorder_order_type_id': None,
            'backorder_action_type': 'ask',
            'store_id': None,
            'partner_id': None,
            'reservation_method': 'at_confirm',
            'reservation_time_before': 0,
            'allowed_package_ids': [],
            'exclusive_package_ids': None,
            'is_homogeneity': False,
            'is_allow_create_package': True,
            'is_can_create_order_manualy': True,
            'is_overdelivery': False,
            'created_by': user_1_company_2_id,
            'edited_by': user_1_company_2_id,
            'barcode': '2132132131231',
            'strategy': 'fefo',
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
        {
            'id': order_type_out_company_2,
            'company_id': company_2_id,
            'prefix': 'OUT',
            'title': 'OUT',
            'order_class': 'incoming',
            'allowed_location_src_ids': [location_buffer_company_2, ],
            'exclusive_location_src_ids': None,
            'allowed_location_dest_ids': [location_partner_company_2, ],
            'exclusive_location_dest_ids': None,
            'backorder_order_type_id': None,
            'backorder_action_type': 'ask',
            'store_id': None,
            'partner_id': None,
            'reservation_method': 'at_confirm',
            'reservation_time_before': 0,
            'allowed_package_ids': [],
            'exclusive_package_ids': None,
            'is_homogeneity': False,
            'is_allow_create_package': True,
            'is_can_create_order_manualy': True,
            'is_overdelivery': False,
            'created_by': user_1_company_2_id,
            'edited_by': user_1_company_2_id,
            'barcode': '2132132131231',
            'strategy': 'fefo',
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
        {
            'id': order_type_int_company_2,
            'company_id': company_2_id,
            'prefix': 'INT',
            'title': 'Internal type',
            'order_class': 'incoming',
            'allowed_location_src_ids': [],
            'exclusive_location_src_ids': None,
            'allowed_location_dest_ids': [],
            'exclusive_location_dest_ids': None,
            'backorder_order_type_id': None,
            'backorder_action_type': 'ask',
            'store_id': None,
            'partner_id': None,
            'reservation_method': 'at_confirm',
            'reservation_time_before': 0,
            'allowed_package_ids': [],
            'exclusive_package_ids': None,
            'is_homogeneity': False,
            'is_allow_create_package': True,
            'is_can_create_order_manualy': True,
            'is_overdelivery': False,
            'created_by': user_1_company_2_id,
            'edited_by': user_1_company_2_id,
            'barcode': '2132132131231',
            'strategy': 'fefo',
            'created_at': datetime.now(),
            'updated_at': datetime.now(),
        },
    ])

    order_inc_company_1 = uuid4().__str__()
    order_out_company_1 = uuid4().__str__()
    order_int_company_1 = uuid4().__str__()
    order_inc_company_2 = uuid4().__str__()
    order_out_company_2 = uuid4().__str__()
    order_int_company_2 = uuid4().__str__()
    op.bulk_insert(Order.__table__, [
        {
            'id': order_inc_company_1,
            'number': 'number',
            'company_id': company_1_id,
            'order_type_id': order_type_inc_company_1,
            'parent_id': None,
            'external_number': 'order_inc_company_1',
            'store_id': store_1_company_1_id,
            'partner_id': None,
            'lot_id': None,
            'origin_type': 'Purchase Order',
            'origin_number': 'Some Purchase Order Number',
            'planned_date': datetime.now(),
            'actual_date': None,
            'created_by': user_1_company_1_id,
            'edited_by': user_1_company_1_id,
            'expiration_date': datetime.now(),
            'users_ids': None,
            'description': 'description',
            'status': 'draft'
        },
        {
            'id': order_out_company_1,
            'company_id': company_1_id,
            'number': 'number',
            'order_type_id': order_type_out_company_1,
            'parent_id': None,
            'external_number': 'order_out_company_1',
            'store_id': store_1_company_1_id,
            'partner_id': None,
            'lot_id': None,
            'origin_type': 'Shipment Order',
            'origin_number': 'Shipment',
            'planned_date': datetime.now(),
            'actual_date': None,
            'created_by': user_1_company_1_id,
            'edited_by': user_1_company_1_id,
            'expiration_date': datetime.now(),
            'users_ids': None,
            'description': 'description',
            'status': 'draft'
        },
        {
            'id': order_int_company_1,
            'company_id': company_1_id,
            'number': 'number',
            'order_type_id': order_type_int_company_1,
            'parent_id': None,
            'external_number': 'order_int_company_1',
            'store_id': store_1_company_1_id,
            'partner_id': None,
            'lot_id': None,
            'origin_type': 'Internatl Order',
            'origin_number': 'Internal',
            'planned_date': datetime.now(),
            'actual_date': None,
            'created_by': user_1_company_1_id,
            'edited_by': user_1_company_1_id,
            'expiration_date': datetime.now(),
            'users_ids': None,
            'description': 'description',
            'status': 'draft'
        },
        # Company 2
        {
            'id': order_inc_company_2,
            'company_id': company_2_id,
            'number': 'number',
            'order_type_id': order_type_inc_company_2,
            'parent_id': None,
            'external_number': 'order_inc_company_2',
            'store_id': store_1_company_2_id,
            'partner_id': None,
            'lot_id': None,
            'origin_type': 'Purchase Order',
            'origin_number': 'Some Purchase Order Number',
            'planned_date': datetime.now(),
            'actual_date': None,
            'created_by': user_1_company_2_id,
            'edited_by': user_1_company_2_id,
            'expiration_date': datetime.now(),
            'users_ids': None,
            'description': 'description',
            'status': 'draft'
        },
        {
            'id': order_out_company_2,
            'company_id': company_2_id,
            'number': 'number',
            'order_type_id': order_type_out_company_2,
            'parent_id': None,
            'external_number': 'order_out_company_2',
            'store_id': store_1_company_2_id,
            'partner_id': None,
            'lot_id': None,
            'origin_type': 'Shipment Order',
            'origin_number': 'Shipment',
            'planned_date': datetime.now(),
            'actual_date': None,
            'created_by': user_1_company_2_id,
            'edited_by': user_1_company_2_id,
            'expiration_date': datetime.now(),
            'users_ids': None,
            'description': 'description',
            'status': 'draft'
        },
        {
            'id': order_int_company_2,
            'company_id': company_2_id,
            'number': 'number',
            'order_type_id': order_type_int_company_2,
            'parent_id': None,
            'external_number': 'order_int_company_2',
            'store_id': store_1_company_2_id,
            'partner_id': None,
            'lot_id': None,
            'origin_type': 'Internatl Order',
            'origin_number': 'Internal',
            'planned_date': datetime.now(),
            'actual_date': None,
            'created_by': user_1_company_2_id,
            'edited_by': user_1_company_2_id,
            'expiration_date': datetime.now(),
            'users_ids': None,
            'description': 'description',
            'status': 'draft'
        },

    ])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute(f"TRUNCATE TABLE {Company.__table__}")
    op.execute(f"TRUNCATE TABLE {Store.__table__}")
    op.execute(f"TRUNCATE TABLE {Role.__table__}")
    op.execute(f"TRUNCATE TABLE {User.__table__}")
    op.execute(f"TRUNCATE TABLE {UomCategory.__table__}")
    op.execute(f"TRUNCATE TABLE {Uom.__table__}")
    op.execute(f"TRUNCATE TABLE {ProductCategory.__table__}")
    op.execute(f"TRUNCATE TABLE {ProductStorageType.__table__}")
    op.execute(f"TRUNCATE TABLE {Product.__table__}")
    op.execute(f"TRUNCATE TABLE {Lot.__table__}")
    op.execute(f"TRUNCATE TABLE {Quant.__table__}")
    op.execute(f"TRUNCATE TABLE {LocationType.__table__}")
    op.execute(f"TRUNCATE TABLE {Location.__table__}")
    op.execute(f"TRUNCATE TABLE {OrderType.__table__}")
    op.execute(f"TRUNCATE TABLE {Order.__table__}")

    # ### commands auto generated by Alembic - please adjust! ###
    op.execute(f"TRUNCATE TABLE {Company.__table__}")
    op.execute(f"TRUNCATE TABLE {Store.__table__}")
    op.execute(f"TRUNCATE TABLE {Role.__table__}")
    op.execute(f"TRUNCATE TABLE {User.__table__}")
    op.execute(f"TRUNCATE TABLE {UomCategory.__table__}")
    op.execute(f"TRUNCATE TABLE {Uom.__table__}")
    op.execute(f"TRUNCATE TABLE {ProductCategory.__table__}")
    op.execute(f"TRUNCATE TABLE {ProductStorageType.__table__}")
    op.execute(f"TRUNCATE TABLE {Product.__table__}")
    op.execute(f"TRUNCATE TABLE {Lot.__table__}")
    op.execute(f"TRUNCATE TABLE {Quant.__table__}")
    op.execute(f"TRUNCATE TABLE {LocationType.__table__}")
    op.execute(f"TRUNCATE TABLE {Location.__table__}")
    op.execute(f"TRUNCATE TABLE {OrderType.__table__}")
    op.execute(f"TRUNCATE TABLE {Order.__table__}")
